package com.weic.easycache.receiver.net;

import android.content.Context;
import android.content.Intent;

import com.weic.easycache.phone.Network;
import com.weic.easycache.phone.Network.State;
import com.weic.easycache.phone.Network.Type;
import com.weic.easycache.receiver.CntObservable;
import com.weic.easycache.receiver.net.NetObservable.Data;

public class NetObservable extends CntObservable<NetObserver, Data> {
	static class Data {
		Type type;
		State state;

		public Data(Context context) {
			type = Network.getNetworkType(context);
			state = Network.getNetworkState(context);
		}
	}

	@Override
	protected Data onParserData(Context context, Intent intent) {
		return new Data(context);
	}

	@Override
	protected void onChange(NetObserver observer, Data data) {
		observer.onChanged(data.type, data.state);
	}
}
